<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>collectInto</title>
</head>

<body>
    <div>打开浏览器控制台查看结果</div>
    <script>
        const collectInto =
            handler =>
                (...args) =>
                    handler(args);
        const Pall = collectInto(Promise.all.bind(Promise));
        let p1 = Promise.resolve(1);
        let p2 = Promise.resolve(2);
        let p3 = new Promise(resolve => setTimeout(resolve, 2000, 3));
        Pall(p1, p2, p3).then(console.log); // [1, 2, 3] (after about 2 seconds)
    </script>
</body>

</html>